module.exports = function (app) {
  const globSync = require('glob').sync
  const mocks = globSync('./mocks/**/*.js', { cwd: __dirname }).map(require)

  // 用于解析body内容
  const bodyParser = require('body-parser')
  app.use(bodyParser.json()) // for parsing application/json
  app.use(bodyParser.urlencoded({ extended: true })) // for parsing application/x-www-form-urlencoded

  // Log proxy requests
  const morgan = require('morgan')
  app.use(morgan('dev'))

  app.set("view engine","ejs");//模版引擎设置为 ejs
  app.set('views',__dirname+'/views')

  mocks.forEach(function (route) { route(app) })
}
